public class Change {
    public int val;//成员变量
    public static void swap(Change change1,Change change2) {//通过对象的引用进行交换对象，Change是类型，change1,change2是形参
        int tmp=change1.val;
        change1.val=change2.val;
        change2.val=tmp;
    }
    public static void main(String[] args) {
     Change change=new Change();
     change.val=10;
     Change change1=new Change();
     change1.val=20;
        System.out.println("交换前:"+"val1="+change.val+" val2="+change1.val);
        swap(change,change1);//实参是change与change1,本质上是地址，但是地址也是一个值
        System.out.println("交换后:"+"val1="+change.val+" val2="+change1.val);
    }
}
